package com.example.teesystem.controller;

import com.example.teesystem.common.utils.Response;
import com.example.teesystem.common.utils.ResultCode;
import com.example.teesystem.entity.vo.IssueRecord.IssueRecordInsertVo;
import com.example.teesystem.service.IssueRecordService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.Map;

/**
 * @author pxr
 * @data 2022/4/14 19:40
 */

@RestController
@RequestMapping(value = "/tee/issueRecord" , produces = "application/json; charset=utf-8" )
@RequiredArgsConstructor
public class IssueRecordController {
    private final IssueRecordService issueRecordService;

    /**
     *
     * @param issueRecordInsertVo
     * @return
     */
    @PostMapping(value = "/addIssueRecord")
    public Response addIssueRecord(@Valid @RequestBody IssueRecordInsertVo issueRecordInsertVo){
        return issueRecordService.addIssueRecordService(issueRecordInsertVo);
    }

    @PostMapping(value = "/radar")
    public Response radar(@RequestBody Map<String,Integer> map){
        Integer courseId = map.get("courseId");
        if(courseId == null){
            return Response.error(ResultCode.PARAMETER_ERROR);
        }
        return issueRecordService.studentRadar(courseId);
    }
}
